package net.ulrice.mdls.sensor;

import java.util.List;

import net.ulrice.mdls.sensor.facade.CpuInfo;
import net.ulrice.mdls.sensor.facade.CpuLoad;
import net.ulrice.mdls.sensor.facade.MemoryInfo;
import net.ulrice.mdls.sensor.facade.NetworkInfo;
import net.ulrice.mdls.sensor.facade.SensorService;

import org.apache.thrift.TException;

public class MdlsSensorFacadeHandler implements SensorService.Iface {

	private Sensor sensor;

	public MdlsSensorFacadeHandler(Sensor sensor) {
		this.sensor = sensor;
	}
	
	@Override
	public int getNumCores() throws TException {
		return sensor.getNumCores();
	}

	@Override
	public List<CpuInfo> getCpuInfo() throws TException {
		return sensor.getCpuInfo();
	}

	@Override
	public List<CpuLoad> getCpuLoad() throws TException {
		try {
			return sensor.getCpuLoad();
		} catch (SensorException e) {
			throw new TException(e);
		}
	}

	@Override
	public List<NetworkInfo> getNetworkInfo() throws TException {
		try {
			return sensor.getNetworkInfo();
		} catch (SensorException e) {
			throw new TException(e);
		}
	}

	@Override
	public MemoryInfo getMemoryInfo() throws TException {
		try {
			return sensor.getMemoryInfo();
		} catch (SensorException e) {
			throw new TException(e);
		}
	}
}